<?php
/*
 * 列表页
 * */
namespace PcHome\Controller;
use Common\Controller\PcHomeBaseController;
class ListController extends PcHomeBaseController {

    const DEFAULT_TEMPLATE = 'list';

    public function index() {
        $cate_id = I('get.cate_id', 0, 'intval');
        $cate = x_get_cate_info($cate_id);
        if(empty($cate)){
            $this->error('列表不存在或已经被删除!');
        }

        $tplname = $cate["list_tpl"];
        $tplname = $tplname ? $tplname : self::DEFAULT_TEMPLATE;
        $this->assign($cate);
        $this->assign('cate_id', $cate_id);
        $this->display(":$tplname");
    }

    public function navList() {
        $navcatname="文章分类";

        $where = array();
        $articleCate = M("CmsArticleCate");
        $datas=$articleCate->field('cate_id,cate_name,parent_id')->where($where)->select();
        $navrule=array(
            'id'=>'cate_id',
            "action"=> 'PcHome/List/index',
            "param"=>array(
                "id"=>"cate_id"
            ),
            "label"=>"cate_name",
            'parentid'=>'parent_id'
        );
        return x_get_all_nav_list($navcatname,$datas,$navrule);
    }
}